﻿<?php

class QueuetypeModel extends BaseModel
{

    var $table  = 'queuetype';	

    var $_page_rows = 20;	
	
     function show()
     {  
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>"",'url' => 'admin/?app=queuetype&act=index'));		
		 $info['data'] = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"",'order' =>'add_time desc','limit' =>$info['page']['sql_limit']));
    
		 return $info;	 

        
     }
     function allshow()
     {  
	
		 $info['data'] = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"",'order' =>'add_time desc','limit' =>$info['page']['sql_limit']));
    
		 return $info;	 

        
     }	 
    function queueshow($order='',$conditions='',$id=0)
    {  
	     empty($order)?$order = ' add_time asc':'';
		 if($conditions)
		 {
   	     $conditions .= " and username !='0' ";		 
		 }else
		 {
   	     $conditions = " username !='0' ";		 
		 }
		  
	     $table = $this->_prefix.'queuemsg';
	  
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('table'=>"{$table}",'conditions' =>"{$conditions}",'url' => 'admin/?app=queuetype&act=queuelist&id='.$id));		
		 
		 $info['data'] = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' * ','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
   
    }
	
    /* 插入数据 */
    function post($data)
    {    
	
  		return $this->IU_Sql_Exe(array ('data' => $data, 'mode' => 'INSERT'));

        
    }


    /* 通过id取出一条数据 */
    function oneshow($id ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));
    
		 return $info;
        
    }


    /* 修改数据 */
    function editaction($id ='',$data = '')
    {    
      
		return $this->IU_Sql_Exe(array ('data' => $data,'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }


    /* 删除数据 */
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));
        
    }

    function queueka($id=0,$order='')
    {  
	     empty($order)?$order = ' add_time asc':'';
   	     $conditions = " queue_id={$id} ";		 
	     $table = $this->_prefix.'queueka';
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('table'=>"{$table}",'conditions' =>"{$conditions}",'url' => 'admin/?app=queuetype&act=queuekalist&id='.$id));		
		 
		 $info['data'] = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' * ','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
   
    }

    /* 删除数据 */
    function delka($id ='')
    {   
	    $table = $this->_prefix.'queueka';	   
		return $this->D_Sql_Exe(array ('table'=>"{$table}",'conditions' =>"id = '{$id}' "));
        
    }

    /* 通过id取出一条数据 */
    function oneshowka($id ='')
    {    
	    $table = $this->_prefix.'queueka';	      
		 $info = $this->S_Sql_Exe(array('table'=>"{$table}",'fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));
    
		 return $info;
        
    }
}




?>